package utils;

import java.awt.*;
import java.awt.event.InputEvent;
import java.util.Random;

public class TestYYS {


    public static void main(String[] args) throws AWTException  {
        //初始化一个机器人
        Robot robot = new Robot();
        //延时
        robot.delay(3000);
        for (int i=0; true; i++){
            robot.mouseMove(randomInt(452,454), randomInt(452,454));//挑战
            click(robot);
            robot.delay(33*1000+randomInt(7000,10000));
            click(robot);
            robot.mouseMove(randomInt(452,454), randomInt(452,454));//另一窗口
            click(robot);
            robot.delay(randomInt(1000,2000));
            click(robot);
        }
    }
    //一个方法，用于单击左键
    public static void click(Robot robot) {
        int a = randomInt(500,1000);
        robot.delay(a);
        robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        a = randomInt(500,1000);
        robot.delay(a);
        robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
    }

    /*
     * 生成[min, max]之间的随机整数
     * @param min 最小整数
     * @param max 最大整数
     */
    private static int randomInt(int min, int max){
        return new Random().nextInt(max)%(max-min+1) + min;
    }
}